/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-05-29
 * Time: 17:09
 */
public class test5 {
        public static void main(String[] args) {

            String str = "aaaabbbcccddd";
            // System.out.println(str);
            int ret = findStr(str);
            System.out.println(ret);

        }

        public static int findStr(String str){
            // System.out.println("1");
            char[] ch = str.toCharArray();
            int n = str.length();
            int right = 0;
            int left = 0;
            int[] hash = new int[128];
            int ret = 0;
            while(right<n){
                hash[ch[right]]++;
                while(hash[ch[right]]>1){
                    hash[ch[left]]--;
                    left++;
                    ret = Math.max(ret,right-left+1);
                }
                right++;
            }
            return ret;
        }
}
